package com.ap.core.domain;

import com.ap.core.cxf.jaxb.rtp.UnitOfMeasureCode;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.joda.time.LocalDate;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * User: Ranjit.Singh
 */
@Entity
@Table(name = "T_ORDER_PRODUCT_DETAIL")
@AttributeOverride(name = "id",column = @Column(name = "order_product_detail_id"))
@TypeDef(name = "id", typeClass = Long.class)
public class OrderProductDetail extends Identifiable<Long>{

    private static final long serialVersionUID = -364876478234786238L;

    @Column(name = "PRODUCT_CODE")
    private String productCode;

    @Column(name = "PRODUCT_DESCRIPTION")
    private String productDescription;

    @Column(name = "MEASURE_UNIT_CODE")
    @Enumerated(EnumType.STRING)
    private UnitOfMeasureCode measureUnitCode;

    @Column(name = "PRODUCT_QUANTITY")
    private BigDecimal productQuantity;

    @Embedded
    @AttributeOverride(name = "value", column = @Column(name = "UNIT_PRICE"))
    private Amount unitPrice;

    @Embedded
    @AttributeOverride(name = "value", column = @Column(name = "PRODUCT_AMOUNT"))
    private Amount productAmount;

    @Column(name = "MISC_PRODUCT_INFO")
    private String miscProductInfo;

    @Column(name="ap_txn_id")
    private String apTransactionId;

    @Column(name = "reconciliation_cycle_id")
    private String  reconciliationCycleId;

    @Column(name = "reconciliation_date")
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentLocalDate")
    private LocalDate reconciliationDate;

    private OrderProductDetail(){}

    public OrderProductDetail(Long id, String apTransactionId, String productCode, Amount unitPrice, Amount productAmount, String reconciliationCycleId, LocalDate reconciliationDate) {
        this.id = id;
        this.productCode = productCode;
        this.apTransactionId = apTransactionId;
        this.unitPrice = unitPrice;
        this.productAmount = productAmount;
        this.reconciliationCycleId = reconciliationCycleId;
        this.reconciliationDate = reconciliationDate;
    }



    public void setMeasureUnitCode(UnitOfMeasureCode measureUnitCode) {
        this.measureUnitCode = measureUnitCode;
    }

    public void setMiscProductInfo(String miscProductInfo) {
        this.miscProductInfo = miscProductInfo;
    }

    public void setProductCode(String productCode) {
        this.productCode = productCode;
    }

    public void setProductDescription(String productDescription) {
        this.productDescription = productDescription;
    }

    public void setProductQuantity(BigDecimal productQuantity) {
        this.productQuantity = productQuantity;
    }

    public UnitOfMeasureCode getMeasureUnitCode() {
        return measureUnitCode;
    }

    public String getMiscProductInfo() {
        return miscProductInfo;
    }

    public Amount getProductAmount() {
        return productAmount;
    }

    public String getProductCode() {
        return productCode;
    }

    public String getProductDescription() {
        return productDescription;
    }

    public BigDecimal getProductQuantity() {
        return productQuantity;
    }

    public Amount getUnitPrice() {
        return unitPrice;
    }

    public String getApTransactionId() {
        return apTransactionId;
    }

    public String getReconciliationCycleId() {
        return reconciliationCycleId;
    }

    public LocalDate getReconciliationDate() {
        return reconciliationDate;
    }
}